/*
 * DevicesTimer.c
 *
 *      Author: Honrun
 */
#include "n32g031.h"
#include "DevicesTimer.h"


int8_t cTimer1Init(void)
{
    /* 定时器1 已被用作红外载波信号 */

    return 0;
}

int8_t cTimer3Init(void)
{
    /* 定时器3 已经被当作红外包络信号 */

    return 0;
}

int8_t cTimer6Init(void)
{
    TIM_TimeBaseInitType TIM_TimeBaseStructure = {0};
    NVIC_InitType NVIC_InitStructure = {0};

    /* TIMx clock enable */
    RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_TIM6, ENABLE);

    /* Time base configuration */
    TIM_TimeBaseStructure.Period    = 10000 - 1;
    TIM_TimeBaseStructure.Prescaler = (SystemCoreClock / 1000000) - 1;;
    TIM_TimeBaseStructure.ClkDiv    = 0;
    TIM_TimeBaseStructure.CntMode   = TIM_CNT_MODE_UP;
    TIM_InitTimeBase(TIM6, &TIM_TimeBaseStructure);

    /* Enable the TIMx global Interrupt */
    NVIC_InitStructure.NVIC_IRQChannel         = LPTIM_TIM6_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd      = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

    /* TIMx IT enable */
    TIM_ConfigInt(TIM6, TIM_INT_UPDATE, ENABLE);

    /* TIMx enable counter */
    TIM_Enable(TIM6, ENABLE);

    return 0;
}

int8_t cTimer8Init(void)
{
    /* 被可控硅定时开启占用 */

    return 0;
}
